var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;

gulp.task('browser-sync', ['tpl', 'js'], function() {
    browserSync.init({
        server: {
            baseDir: "./dist/tpl"
        }
    });
    gulp.watch('tpl/*.html', ['tpl']).on('change', reload);
    gulp.watch('js/*js', ['js']).on('change', reload);
});

gulp.task('tpl', function() {
    return gulp.src('tpl/*.html')
        .pipe(gulp.dest('./dist/tpl'));
});

gulp.task('js', function() {
    return gulp.src('js/*.js')
        .pipe(gulp.dest('./dist/js'))
});

gulp.task('default', ['browser-sync']);